import { MockMethod } from "vite-plugin-mock";
// http://mockjs.com/examples.html#Object
const systemRouter = [
  {id:1,pid:0,title:"首页",icon:"icon-shouye",url:"/Home",redirect:"",showLink:true,sort:0,route:"Home",transitionName:'',keepAlive:true},
  {id:2,pid:0,title:"多级菜单",icon:"icon-daohang",url:"/Nested",redirect:"/Nested/Menu1/Menu1-1",showLink:true,sort:1,route:"Nested",transitionName:'',keepAlive:false},
  {id:3,pid:2,title:"菜单1",icon:"",url:"/Nested/Menu1",redirect:"/Nested/Menu1/Menu1-1",showLink:true,sort:0,route:"Menu1",transitionName:'',keepAlive:false},
  {id:4,pid:3,title:"菜单1-1",icon:"",url:"/Nested/Menu1/Menu1-1",redirect:"",showLink:true,sort:0,route:"Menu1-1",transitionName:'fade-bottom',keepAlive:true},
  {id:5,pid:3,title:"菜单1-2",icon:"",url:"/Nested/Menu1/Menu1-2",redirect:"/Nested/Menu1/Menu1-2/Menu1-2-1",showLink:true,sort:1,route:"Menu1-2",transitionName:'',keepAlive:false},
  {id:6,pid:5,title:"菜单1-2-1",icon:"",url:"/Nested/Menu1/Menu1-2/Menu1-2-1",redirect:"",showLink:true,sort:0,route:"Menu1-2-1",transitionName:'fade-scale',keepAlive:true},
  {id:7,pid:5,title:"菜单1-2-2",icon:"",url:"/Nested/Menu1/Menu1-2/Menu1-2-2",redirect:"",showLink:true,sort:1,route:"Menu1-2-2",transitionName:'fade-top',keepAlive:true},
  {id:8,pid:3,title:"菜单1-3",icon:"",url:"/Nested/Menu1/Menu1-3",redirect:"",showLink:true,sort:3,route:"Menu1-3",transitionName:'zoom-out',keepAlive:true},
  {id:9,pid:2,title:"菜单2",icon:"",url:"/Nested/Menu2",redirect:"",showLink:true,sort:1,route:"Menu2",transitionName:'zoom-fade',keepAlive:true},
  {id:10,pid:0,title:"论坛新闻",icon:"icon-luntan",url:"/News",redirect:"/News/Index",showLink:true,sort:2,route:"News",transitionName:'',keepAlive:false},
  {id:11,pid:0,title:"系统管理",icon:"icon-shezhi",url:"/System",redirect:"/System/UserManagement",showLink:true,sort:3,route:"System",transitionName:'',keepAlive:false},
  {id:12,pid:11,title:"用户管理",icon:"",url:"/System/UserManagement",redirect:"",showLink:true,sort:0,route:"UserManagement",transitionName:'',keepAlive:false},
  {id:13,pid:0,title:"百度一下你就知道答案并不在百度",icon:"icon-sousuo",url:"https://www.baidu.com",redirect:"",showLink:true,sort:10000,route:"",transitionName:'',keepAlive:false},
  {id:14,pid:10,title:"新闻列表",icon:"",url:"/News/Index",redirect:"",showLink:false,sort:0,route:"NewsIndex",transitionName:'fade',keepAlive:false},
]

// 判断accessToken是否有效，假定这里已获取到前端回传的accessToken
const isAccessTokenValid = ()=>{
  return true;
}
// 判断refreshToken是否有效，假定这里后端已经通过accessToken匹配到了refreshToken
const isRefreshTokenValid = ()=>{
  return true;
}

export default [
  {
    url: "/getAsyncRoutes",
    method: "post",
    response: () => {
      if(isRefreshTokenValid()){
        if(isAccessTokenValid()){
          return {
            code: 200,
            status:true,
            info:"菜单数据获取成功！",
            data: systemRouter
          };
        }else{
          return {
            code: 201004,
            status:false,
            info:"token已失效，请更新token！",
            data: []
          };
        }
      }else{
        return {
          code: 201002,
          status:false,
          info:"登录已超时，请重新登录！",
          data: []
        };
      }
    }
  }
] as MockMethod[];